<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateFilterableAssetBundlesTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('filterable_asset_bundles', function (Blueprint $table) {
            $table->bigIncrements('id');
            $table->string("name")->unique();
            $table->text("description");
            $table->unsignedBigInteger('created_by');
            $table->timestamps();
            $table->softDeletes();
            $table->foreign('created_by')->references("id")->on("users");
        });

        Schema::create('filterable_asset_bundle_criteria', function (Blueprint $table) {
            $table->bigIncrements('id');
            $table->unsignedBigInteger('bundle_id');
            $table->string('asset_type');
            $table->string('field_name');
            $table->string('field_value');
            $table->string('operator')->default('=');
            $table->integer('quantity')->default(1);
            $table->softDeletes();
            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('filterable_asset_bundle_criteria');
        Schema::dropIfExists('filterable_asset_bundles');
    }
}
